#include "ia.h"

bool BinomialProba(float p)
{
    if(p>0&&p<=1)
    {
        int proba = sf::Randomizer::Random(0.f,10.f);
        if(proba<= p)
            return true;
        else
            return false;
    }
    else
        return false;
}
Condition_Rapprocher::Condition_Rapprocher(int id_unite, int type_decision, int id_unite_adversaire)
{
    m_id_unite = id_unite;
    m_id_unite_adversaire = id_unite_adversaire;
    m_type_decision = type_decision;
}
int Condition_Rapprocher::GetInput(std::vector<Unite*> unite,std::vector<sf::Sprite*> m_batiment, Terrain *terre)
{
    switch(m_type_decision)
    {
        //Attaque unite
        case 0:
        sf::Vector2f positionunite(unite[m_id_unite]->GetPosition()), positionadversaire(unite[m_id_unite_adversaire]->GetPosition());
        if(is_in(positionunite.x-positionadversaire.x,-1000,1000)
        {
            bool tir_canon;
            if(unite[m_id_unite]->GetType() == TANK)
            {
                tir_canon = true;
            }
            else
            {
                tir_canon = false;
            }
        }
        else
        {
           if(positionunite.x>positionadversaire.x)
           {
               return 4;
           }
           else
           {
               return 3;
           }
        }
    }
}
Ia::Ia(Equipe* equipe)
{
    m_equipe = equipe;
    phase_detection = true;
    phase_deplacement = false;
    phase_final = false;
}
int Ia::Reflexion(sf::RenderWindow *app, Game *jeu, std::vector<Unite *> unite, int id)
{
    //initialisation des variables
    int retour(0);
    if(phase_detection)
    {

    }
}
